package site.jlopen.controller.modules;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import site.jlopen.assets.config.ThreadAuthUser;
import site.jlopen.domain.node.event.KusciaNodeEvent;
import site.jlopen.domain.node.event.KusciaNodeRouteEvent;
import site.jlopen.entity.BaseResponse;
import site.jlopen.entity.node.RouteSearchResult;
import site.jlopen.service.BaseService;

@RestController
@RequestMapping("/nodeRoute")
public class NodeRouteController extends BaseService{
	
	@PostMapping("/bind")
	public BaseResponse<String> bind(Long srcNode, Long dstNode, int bindType) {
		return nodeRouteService.bind(ThreadAuthUser.id(), srcNode, dstNode, bindType);
	}

	@GetMapping("/list")
	public List<KusciaNodeRouteEvent> list() {
		return nodeRouteService.list(ThreadAuthUser.id());
	}

	@GetMapping("/unbind")
	public BaseResponse<String> unbind(Long routeId) {
		return nodeRouteService.unbind(routeId);
	}

	@GetMapping("/delNode")
	public BaseResponse<String> delNode(Long routeId) {
		return nodeRouteService.delRoute(routeId);
	}

	@GetMapping("/restatus")
	public BaseResponse<String> restatus(Long routeId) {
		return nodeRouteService.restatus(routeId);
	}

	@GetMapping("/nodesByRoute")
	public List<KusciaNodeEvent> nodesByRoute(Long nodeId) {
		return nodeService.listByRouteUser(ThreadAuthUser.id(), nodeId);
	}

	@PostMapping("/search")
	public BaseResponse<RouteSearchResult> search(Long srcNode, Long dstNode) {
		return nodeRouteService.search(srcNode, dstNode);
	}
}
